package com.dashboard.common.utils;

import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.message.AbstractHttpMessage;
import org.apache.http.message.BasicHeader;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;

import java.io.*;
import java.net.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 * @author Administrator
 */
public class HttpUtils {

    private static PoolingHttpClientConnectionManager cm;
    private static String EMPTY_STR = "";
    private static String UTF_8 = "UTF-8";
    private static RequestConfig requestConfig;
    /** 设置连接超时时间，单位毫秒。*/
    private static final int CONNECT_TIMEOUT = 600000;
    /** 设置从connect Manager获取Connection 超时时间，单位毫秒。这个属性是新加的属性，因为目前版本是可以共享连接池的。*/
    private static final int CONNECTION_REQUEST_TIMEOUT = 5000;
     /** 请求获取数据的超时时间，单位毫秒。 如果访问一个接口，多少时间内无法返回数据，就直接放弃此次调用。*/
    private static final int SOCKET_TIMEOUT = 600000;
    /**
     * 初始化，很多人喜欢使用懒加载，在使用的时候再进行初始化，我个人认为，已经确定要用的资源，最好启动的时候就加载
     * 即使会慢一点，也比中途出现突然的加载加压好一点，而且如果有问题也能提前曝出，不会等着真正要用的时候，才开始
     * 邹眉头
     */
    private static void init() {
        cm = new PoolingHttpClientConnectionManager();
        // 整个连接池最大连接数
        cm.setMaxTotal(10);
        // 每路由最大连接数，默认值是2
        cm.setDefaultMaxPerRoute(5);
        //请求配置
        //   setConnectTimeout：设置连接超时时间，单位毫秒。
        //	 setConnectionRequestTimeout：设置从connect Manager获取Connection 超时时间，单位毫秒。这个属性是新加的属性，因为目前版本是可以共享连接池的。
        //	 setSocketTimeout：请求获取数据的超时时间，单位毫秒。 如果访问一个接口，多少时间内无法返回数据，就直接放弃此次调用。
        requestConfig = RequestConfig.custom().setConnectTimeout(CONNECT_TIMEOUT)
                .setConnectionRequestTimeout(CONNECTION_REQUEST_TIMEOUT).setSocketTimeout(SOCKET_TIMEOUT).build();
    }
    /**
     * 通过连接池获取HttpClient
     *
     * @return
     */
    public static CloseableHttpClient getHttpClient() {
        return HttpClients
                .custom()
                .setConnectionManager(cm)
                .build();
    }
    public static String httpGetRequest(String url) {
        HttpGet httpGet = new HttpGet(url);
        return getResult(httpGet);
    }
    public static String httpGetRequest(String url, Map<String, Object> params) throws URISyntaxException {
        return httpGetRequest(url,null,params);
    }
    public static String httpGetRequest(String url, Map<String, Object> headers, Map<String, Object> params)
            throws URISyntaxException {
        URIBuilder ub = new URIBuilder();
        ub.setPath(url);
        ArrayList<NameValuePair> pairs = covertParams2NVPS(params);
        ub.setParameters(pairs);
        HttpGet httpGet = new HttpGet(ub.build());
        setHttpHeader(httpGet,headers);
        return getResult(httpGet);
    }
    public static String httpPostRequest(String url) {
        HttpPost httpPost = new HttpPost(url);
        return getResult(httpPost);
    }
    public static String httpPostRequest(String url, Map<String, Object> params) throws UnsupportedEncodingException {
        return httpPostRequest(url,null,params);
    }
    public static String httpPostRequest(String url, Map<String, Object> headers, Map<String, Object> params)
            throws UnsupportedEncodingException {
        HttpPost httpPost = new HttpPost(url);
        setHttpHeader(httpPost,headers);
        ArrayList<NameValuePair> pairs = covertParams2NVPS(params);
        httpPost.setEntity(new UrlEncodedFormEntity(pairs, UTF_8));
        return getResult(httpPost);
    }
    public static String httpPostRequest(String url, Map<String, Object> headers, String strBody)
            throws Exception {
        HttpPost httpPost = new HttpPost(url);
        setHttpHeader(httpPost,headers);
        httpPost.setEntity(new StringEntity(strBody, UTF_8));
        return getResult(httpPost);
    }
    private static ArrayList<NameValuePair> covertParams2NVPS(Map<String, Object> params) {
        ArrayList<NameValuePair> pairs = new ArrayList<NameValuePair>();
        for (Map.Entry<String, Object> param : params.entrySet()) {
            pairs.add(new BasicNameValuePair(param.getKey(), String.valueOf(param.getValue())));
        }
        return pairs;
    }
    /**
     * 处理Http请求
     *
     * setConnectTimeout：设置连接超时时间，单位毫秒。
     * setConnectionRequestTimeout：设置从connect Manager获取Connection 超时时间，单位毫秒。这个属性是新加的属性，因为目前版本是可以共享连接池的。
     * setSocketTimeout：请求获取数据的超时时间，单位毫秒。 如果访问一个接口，多少时间内无法返回数据，就直接放弃此次调用。
     *
     * @param request
     * @return
     */
    private static String getResult(HttpRequestBase request) {
        // 设置请求和传输超时时间
        request.setConfig(requestConfig);
        // CloseableHttpClient httpClient = HttpClients.createDefault();
        CloseableHttpClient httpClient = getHttpClient();
        try {
            //执行请求
            CloseableHttpResponse response = httpClient.execute(request);
            // response.getStatusLine().getStatusCode();
            HttpEntity entity = response.getEntity();
            if (entity != null) {
                // long len = entity.getContentLength(); -1 表示长度未知
                String result = EntityUtils.toString(entity);
                response.close();
                // httpClient.close();
                return result;
            }
        } catch (ClientProtocolException e) {
            throw new RuntimeException( "HttpClientUtil IOException ：" +e.getMessage());
        } catch (IOException e) {
            throw new RuntimeException( "HttpClientUtil IOException ：" + e.getMessage());
        } finally {
        }
        return EMPTY_STR;
    }
    /**
     * 设置对象头
     *
     * @param http
     * @param headers
     */
    public static void setHttpHeader(AbstractHttpMessage http, Map<String, Object> headers) {
        if (isEmpty(headers)) {
            return;
        }
        headers.entrySet().stream().forEach(entry -> {
            String key = entry.getKey();
            String value = String.valueOf(entry.getValue());
            http.addHeader(new BasicHeader(key, value));
        });
    }
    /**
     * 判断Map是否为空
     *
     * @param map
     * @return null 或者 size = 0 返回true, 其他返回false
     */
    public static boolean isEmpty(Map map) {
        return null == map || map.size() == 0;
    }
    public static void main(String[] args) throws Exception {
        Map<String,Object> params = new HashMap<>();
        Map<String,Object> headers = new HashMap<>();
        headers.put("content-type","application/json");
        JSONObject obj = new JSONObject();
        String sqlStr = "select count(keyWord) h,keyWord a from keywordpro where dataId in (475143,1663001,1695769,16385,475142,1695768,1830938,1306647,1077273,1695760,114699,167944,1695762,684039,475145,475144,1695755,1695757,1830927,1081354,131100,1695751,1282060,1695750,77856,200737,16419,1105974,1695806,1105979,114733,184366,1302590,114734,98353,1888301,1888296,1888297,114743,49208,1888292,204858,1888293,1888295,1888289,1888290,1888291,471111,1630298,77893,139333,1884251,1601616,1630291,90193,1196096,139345,184401,90197,1601613,159828,794714,61531,1282124,184423,1880181,155759,393323,880765,192625,880766,708735,53367,1474657,1302636,159875,1626267,159878,823432,1187994,90251,790662,168078,1175709,61582,180365,1888396,192662,1679488,135321,303263,1106061,65697,1269939,1536183,1663161,1269938,90274,90282,1695922,1269950,1269948,168113,82102,1560736,1269934,180412,1695960,98500,98507,110796,831683,1695958,57554,1077442,700633,1695948,717009,1663170,1663173,1601734,1503479,1888509,1601787,1601788,1601789,1695999,1888507,479471,1888500,1601777,1888501,1601778,1175802,12524,1302783,1601780,1425656,1601781,1888497,119023,1270013,1888492,114930,1663210,1888495,1663213,1663214,98553,1720547,1630488,1749274,1601817,1749275,1630490,98565,1601821,1601822,1749276,1630480,1630481,1601810,98570,1601811,127245,1630484,196878,1601813,82194,82197,1630478,1888522,1888516,90392,1888517,1888518,1888514,1462582,1667387,1667388,33066,119082,135469,1601832,37169,1630505,57651,65844,28983,475455,1601824,1630497,45370,135486,1630500,1749286,1601831,1630503,1749285,151874,1864030,1163611,1302873,475464,1302876,168286,45405,1302861,1888578,1888579,1585530,1282423,1888632,1306998,1888633,1888629,1282425,1888630,1257848,1536380,1888631,1888624,1888625,90482,1630617,135553,82313,98697,123273,471436,160142,106892,1888657,110990,70035,135569,106909,115103,168354,61857,172448,1630650,135591,151972,1532337,1077687,1532336,143786,717218,1630643,1630646,1630632,455095,1532335,1630624,1532332,119228,1323434,1667545,1696219,1667546,160198,1667549,471489,1667551,1667550,1270235,1696208,1667541,90572,1667543,1360347,1552856,1630679,1667542,49617,1630666,115154,164310,471507,1630668,471506,1696204,45527,1630656,1302986,41436,1155533,78300,98782,90600,1696245,98799,1663479,1888754,1667560,1667563,1888750,1663466,143862,1667565,1630701,1667564,1696236,1630702,1667567,819707,1630703,1667566,1667553,1696225,98808,168443,1667555,1663461,1630693,1667556,1667559,1630695,1667558,1692189,119300,1888794,49671,1106455,49672,1888789,1749520,1888790,160270,1888785,82447,451080,1307165,1409563,1888786,1888787,1749514,1749515,823839,1749513,1888783,717342,1749518,823833,1749519,176666,1749507,1749504,823831,1307148,1749509,1749562,1081905,1700408,1081906,1700411,1749561,1749567,1749565,1700400,1700402,1749559,1700407,115249,143922,471605,143921,1344032,66100,1700398,66106,123450,164414,1667672,1008205,41540,1229398,1667677,123460,1667676,1667678,176714,1667665,57929,1630801,1667667,160329,164425,1667666,1667669,160332,1667671,1667670,1696329,213586,1667656,143952,1667659,1696331,82514,1667661,1749582,1630797,1749583,1630798,1749580,1630799,1696334,1749570,205402,1749571,143960,1667651,1749569,1667653,1577541,1667652,582230,176733,1749573,1888892,131683,1888893,1749624,1888895,1630844,1720958,1888889,1749628,1888890,1360499,164458,1749618,1086073,1725043,1749619,1888885,1888886,1630837,205421,1602166,205420,1602167,717434,1667689,717435,1602154,1802856,709244,717436,152184,1667683,619125,143999,1774182,160386,127618,1720990,119431,1749648,115342,119438,1008256,156307,1749640,1700493,1749646,1749647,82582,905882,1749645,1630848,1725058,1749634,1725056,1630852,1725062,1749638,74396,1749639,1888897,1663623,1749636,1888898,131745,62116,717487,127657,1888951,168623,164524,1721012,1798827,1888940,717496,193206,1888937,1450656,1888934,1606310,1700518,160450,1888988,1888989,1692379,1888990,1282768,1888984,1749727,135876,1888986,1749725,1888987,1888982,238280,1888977,1888979,144082,197330,78548,131796,1282757,90845,53984,1725178,1749753,1749758,783075,1282811,1749746,127722,1663730,1749745,1749750,176876,1749748,172786,1749739,1889006,1684202,1749743,123639,1663713,1749731,1749728,1446637,1749734,1749733,1696536,111362,1631007,1630992,1041158,1696528,1041157,1725200,1696533,1696534,1725194,713497,1749769,1630988,13077,99095,1749772,1696515,115482,144159,1749767,168732,475929,475936,1725232,1725239,1725236,1631017,1725227,115507,1631020,115517,1631013,1725273,123717,1246039,1696604,1426259,111430,1696606,1606480,1725268,29519,1725269,58193,45906,1700683,168785,1700685,29534,1606470,1614712,1631096,1889148,476006,476005,1631098,1631099,1282935,201572,1282939,1889140,1889141,1282937,1614706,1631092,177004,1282941,1606504,1889133,471925,1889134,1696613,1696612,168829,983920,1282962,70530,1282960,140167,832388,1721234,1086361,1602451,1721233,156556,123790,152466,1282946,1282944,1282951,1721228,1282955,1282954,1745795,33690,1282952,1631107,1282959,119708,144287,1057714,1495986,1086390,1303477,1889204,1283002,1532862,1303481,107436,1532858,144300,1692598,463792,1868711,144316,1631192,1668057,156608,1532885,107458,1532884,1631195,1668058,1889240,115652,1668060,1889241,1889242,1532880,1668049,1729490,1889237,1889238,1221593,1500125,1889239,1631188,50125,1668052,1889233,168909,1692617,156624,1532869,1889230,1532868,82901,160727,1532866,82903,1532865,1631182,70618,1409998,152543,1532874,82911,1668039,1631175,1668038,1750010,1889276,1889277,1352695,1889279,1750014,1889272,1889275,144363,1631218,1750000,1295358,1668073,91120,1631211,1668074,1631212,58357,177140,1180645,1668065,1086441,1631205,1823718,156669,1668070,41985,173059,148491,160776,1086493,807966,807967,136214,1606670,1750018,1451021,1889280,99356,1889283,1283122,1283121,1827901,1819698,1606706,1664051,807968,1082428,807969,1700916,1700905,1643560,123955,152625,33845,152628,1664047,1664046,132154,144450,1750106,1750105,1668189,58437,42055,1078359,1668190,1721427,62539,17484,1889356,1889357,144465,107605,156758,1721422,66646,1700929,148571,173144,128093,480344,1700934,1668217,1668218,1721470,1889401,185444,1332339,185455,832611,1668205,1668204,1045625,58487,128121,775283,1668195,87164,1668196,1844321,1668198,1348756,46211,197767,1660060,1889433,1102998,1205402,1303711,124044,1750164,1721482,1750153,152726,103577,1889412,29849,1283210,472221,1369225,165021,1598649,1545397,1598651,1746105,1598652,1270966,1598653,87207,1598654,1664191,1193141,79018,1598643,87213,148654,1598644,1598646,472232,894141,1270946,824511,29879,128184,1729702,1746085,1750181,1598680,1598681,1598682,1598684,1721566,74948,1598685,1721567,120007,152772,1598686,58567,1598687,1598672,1598673,1598674,107724,62672,34001,1537222,1598666,1598667,1598668,156887,1598669,1598671,136410,1598656,1746115,120027,132312,1598658,206040,1598662,1746116,685294,1377520,1668351,1668337,1721584,156905,120045,1406201,1668341,50413,1668340,66799,1668343,87278,1869043,83187,1721576,1668333,173303,1668332,1721580,181498,1598688,1598689,1668320,1721571,197881,1545453,1721569,1823968,1721574,189692,824562,1266963,1631504,1873173,144649,1631508,1668373,1668372,1631511,1668374,1668361,1082627,1275136,1668365,173332,1668353,1434892,83227,1103115,1668354,185631,1668356,107809,103716,189735,1668412,136484,1668414,1086778,1086779,1668402,181554,189745,1668385,144702,1668389,66876,1668388,1746267,50504,1746262,128335,144716,58707,124245,472403,472402,206164,148824,1791303,124255,1664369,1078649,1770866,103788,124268,1664374,214386,144752,42355,1385837,128376,152955,1664354,1746273,169342,1013106,1746277,1668505,1746330,1594778,140673,1594779,103812,1201562,152968,107916,107918,1746325,1594761,1697163,824735,1668490,1746313,1746319,189844,1668495,1668494,1697166,128409,1697155,1697157,1746310,1746311,1697159,1668536,128419,1668539,136609,832943,1668538,1594812,144804,1086903,1086905,136616,1107386,1668533,1668520,161200,1086883,103862,153013,1668515,1746336,1537450,1594789,1537449,1598940,71108,1668572,1598942,95688,181704,1668567,1594824,144849,1594828,1668557,83412,1668556,95703,1594831,120281,124376,1668547,1668546,103901,107996,136671,1594821,1594822,1668551,1668550,177635,1594864,1598960,1598961,38379,1811958,1594870,1594871,198131,1598952,476662,1594857,1598953,476661,132593,1873391,1881583,46580,161270,1598956,185847,1598957,153076,1594863,476671,1598944,140795,476670,1598945,1598946,132601,1598947,1598948,1078765,1598949,1598950,1535,476664,153091,157187,1086993,58883,1680924,50696,157193,120332,136726,108055,714260,833043,1664568,71202,1766969,1766974,1664560,456237,1664565,1766964,456233,128565,153142,91702,42554,1697316,165436,685643,108098,128582,1394269,472653,1766992,157262,1300062,108111,153170,157267,1078850,1664587,1664586,1787464,1664589,1766990,42581,1078853,1078854,1664591,1078855,1730125,1078856,1078857,1697344,1078858,1078859,1664578,1730113,1697350,833132,1271410,1271409,1697403,67170,1635964,1726078,1635966,1726076,1300084,1635952,177771,1697397,1767029,1767018,833149,833145,1697391,99958,1635951,87674,145020,1697383,1721956,1697382,1078931,1664666,1250974,1664663,202386,595608,1300100,1664654,1635968,1300104,1300111,1103501,1599160,714408,1599162,1599163,1595069,1599165,1799870,1636030,1201845,1599167,1599152,181931,1599153,1500861,1599155,1599156,1599157,1599158,1599159,120497,124595,1447588,1599146,30389,1648300,149172,1599150,1599151,1664673,1664672,1701536,1820327,1857184,1664678,1218258,120512,186048,1668826,714447,1599184,1599185,1599186,59085,833218,1636055,1595080,1599176,1599178,149204,1599182,153301,1599183,1599168,1595073,1599169,1636033,1599170,1599172,1636036,1599173,1787590,1599174,83682,1459957,132838,173798,1791741,1095415,34536,1095416,194283,1824498,108267,132846,1664746,1824493,1570528,141048,1767136,1300207,1664741,1664742,38656,1271571,1599256,100096,1271570,1013517,1271569,1599258,165633,1271568,1599261,1599262,1599263,165642,1599250,1599251,1726230,87820,1271555,1378053,1599240,1271554,1599241,1271553,825119,1271552,1599243,1271559,1304327,1271558,1767183,1271557,5911,1271556,1271563,1271562,136984,1271560,1271567,1304335,1271566,1271564,108322,1767231,83750,1107768,1722161,1668917,177964,1668906,46902,1107750,1668911,83766,1668910,1300267,1599264,1668897,1599265,1300271,1300270,1300268,128833,1664860,1664863,677699,1328989,124747,1664850,714587,1300290,128850,1300293,1267529,1267528,1632067,1664889,1726331,1304438,1664894,132968,1664883,1304446,1664872,1664875,1664874,1668970,165751,46966,1664878,1668974,1664865,1103761,1636249,14210,1636251,1636252,51079,108422,1726354,1767314,1726355,804742,1636247,1726357,161682,1726346,30609,59281,149392,1767304,161686,1726350,1304454,210837,1726338,1664896,1726339,1726337,63388,1726343,128927,1726340,1726341,1767301,714670,1595325,1595326,1595327,128937,1636275,1304511,1595317,1595318,149426,714682,1636264,714683,714680,1636266,714681,1636267,714684,1595296,1636256,714672,153529,1324975,714678,174012,714676,1271725,1595352,1636312,1636314,1664987,22468,1636316,1664991,133061,1636319,1595344,1636304,1636306,1566684,1595347,1300447,88012,108492,1636310,1595351,1636311,108497,1271747,1722312,137169,161745,1337280,1361858,1595342,161755,1460175,1722307,108506,1595331,473063,108515,473061,473060,473059,1595388,473064,1726442,1087458,1595370,1087459,1882095,473075,1726447,1107942,1595360,1783778,1370095,1636323,1664994,1783783,1648612,1664996,1726436,1595367,1726437,1374230,83976,1636369,108554,149518,133138,1103873,1636363,1636365,1865737,1636366,1103881,133151,124958,1300531,1620024,124960,190499,1726526,1300534,260133,1501246,1566783,141352,1566780,1095743,133171,129075,1447972,1103912,161851,141374,661558,821324,723018,899151,821323,211017,1546333,149582,1275998,1300547,821342,174161,821343,1566786,821338,1726529,477274,1271886,1726532,1726533,1300595,1726584,477283,1726590,1726578,1747058,116843,821344,1726582,1726583,190572,153714,51314,1726568,137329,821375,1222753,1783912,166007,821365,1153133,1300591,1726565,1783908,821391,821384,141444,161931,1783953,108685,1783957,1042560,1783956,182418,821407,1783950,821397,207007,1865856,100510,1300620,1648827,153766,92324,100516,1747135,1767615,1329343,1104062,1382587,1104063,854206,1722537,71863,75958,116925,1300655,1595608,1693913,1767640,452802,1079508,125127,1079510,1079511,473294,1079513,1693904,1079514,1079515,1300696,1079516,1628372,1693909,1079517,1079518,1808597,1079519,1108162,1202368,1628362,1108163,116949,1108165,1628365,100566,129242,1267919,198878,1628358,1267916,1628359,133346,92384,1665275,1665274,1759481,1665276,1771773,71913,1104120,1640689,1104121,1665264,1104122,71914,129258,1104123,1640690,1665266,665830,1104124,1329400,1104127,1079520,207090,1079521,63731,1079523,1079525,141556,1566945,1079527,1079528,1566959,1693921,55545,1640677,1693924,1665255,1300755,92419,1722648,174337,1722649,1354000,149767,1722655,1726751,39174,153860,1378579,133381,1837339,1726739,833799,51470,76049,1300739,1300738,125202,1726729,1636623,1636608,1665281,1636609,1726726,100636,1304846,1378568,1665284,1300749,39199,1665286,112928,137504,1640762,325920,149797,1640757,1640756,1669428,1640759,207153,1427751,112951,1726764,1345827,1108269,1280301,125246,1489193,158019,1665368,1640797,1640796,1096023,1595743,22856,158026,186698,1079640,1079641,1665360,84299,112971,133454,1665365,1640778,1214791,1640780,1665359,1640782,1825100,821588,1747266,1214792,112989,145759,55646,1440075,158051,1595769,1726843,117090,166246,1726846,108907,149864,211304,129391,833891,1882483,1595755,113013,1665377,117115,1108330,1640807,133506,1694105,27009,137600,55683,1694106,63877,1763729,1726871,1403290,1300866,1628554,1726862,178583,346515,1628558,256404,1628559,1694094,821653,821655,1083787,55709,821651,1300912,170406,1640893,186789,1640894,1083832,1767858,166315,117162,178601,1083836,1825206,59822,1825205,1821097,1767855,43446,1694113,1767842,1681824,1694115,1300904,1104301,1870241,113087,149948,1104302,22978,1812953,1636818,1858006,117194,1636821,1636823,186834,1014239,1423813,1870284,113111,1083847,76251,117211,711120,113119,109025,109026,133601,1300976,1083893,1300986,1673712,117229,1083901,817634,51696,739835,1673707,1673708,150004,59895,739836,1673710,1300971,1239528,1636836,154114,190979,1083922,133636,1640991,1677843,1636873,1300997,1542671,186904,1636866,1636867,1636869,1694267,1694269,150055,1104438,1641008,211503,80435,1641005,121399,780860,1104423,1640992,162367,186946,1301075,1641049,1698393,1272402,43588,2632,1301082,1301081,1698389,1698391,141901,1698390,117328,1370694,1669707,1083971,1669706,1669709,1694272,1669699,1694275,1669698,1083981,1669703,1669702,817772,1301105,1280631,80486,1641086,84585,154216,1641075,1641074,313961,1043041,133745,146039,1829473,1272424,1280616,47741,1444457,76421,51850,1079963,55950,1301149,199308,461448,133779,846494,68246,146074,1792642,723607,1301134,1768068,1301132,1768069,711338,1698493,1723070,27301,1698492,1698495,1698494,109225,166570,1727155,121517,166572,158388,1301157,117437,1161901,1751719,80574,1596121,1080019,150212,1596113,1813201,1596116,35534,51920,1280707,68309,1747663,166613,146138,1698496,15066,834262,146142,1301239,105195,92908,125678,1596136,1268453,1596129,1596130,826096,1596132,1596135,1424151,723724,1596179,146190,133901,1669910,146195,1760011,658207,1583872,1161992,1280777,1669890,1501962,1084173,1669892,1280781,154402,1698618,154404,1301301,158501,1698622,121640,1641257,142129,1301280,1669921,1788707,154427,158529,1698650,1297238,817994,1698654,1579858,64335,84817,469846,1698632,1600331,39764,133975,1698638,1502030,1698626,101212,146269,1665917,1665919,244580,1665908,1354618,134002,1301346,1080162,1080163,1665901,154484,80763,179065,1698660,142204,1301356,1739673,1268631,1633180,1633181,1633182,469903,187275,469900,985988,56206,109455,469897,1633174,199570,56210,1665931,826265,179098,469919,1665921,56219,1571724,1665922,1248143,1813382,187292,72609,723881,1108914,1633210,1633211,1633212,1633213,1747890,1633201,1633202,1301439,68527,1633206,146354,150450,187314,1633192,1633194,1723304,1633195,1633196,1723310,1633198,1723308,1846180,1633185,1633186,1723302,1633190,1788837,1670105,1747930,1747931,1670107,1670106,1670111,1428434,1670097,1698770,48079,1412037,1084355,1858504,1301445,1633216,801750,1633218,1788865,1633219,1633220,179167,1502152,1633222,1633223,625640,1858557,1698811,56292,113636,142311,469986,1698812,1502192,1698814,56296,138218,1571838,1698800,1698803,117738,1698802,1670133,1698805,1698807,1698793,1698795,113650,1698797,1698796,1698799,1670112,158718,1698790,125953,723979,203778,1301522,1666074,7172,1301527,1440785,1301526,93190,793611,1301524,1666064,1670160,117770,1670162,1666071,93201,723994,723993,1637390,1649678,1666053,1666052,1666055,470055,1670201,130080,1670203,105506,1670202,1670204,72743,1698869,150575,1698868,1301565,212018,945210,1788972,1268778,1670180,64574,1268819,1268818,1301586,1670234,1268823,1268822,126023,1268820,64584,1268827,126027,1268824,52300,138319,1268829,138317,1268828,1666121,1670219,1231942,1301574,1670220,179284,1666127,1268809,1670211,470108,1268808,187487,1268814,1670212,1268812,1571959,1698937,1662077,719981,1698942,1629296,1670257,1698928,109675,1698931,826471,826465,1698935,1698934,1670249,474229,474227,1670253,474225,1629294,1662063,1670254,1703009,1629282,138367,150655,826483,1100911,1768602,1662104,1768600,1629339,1723550,1768606,1580189,138372,208005,105609,826500,1768599,1768596,1424538,113811,1629322,1662092,478353,1698958,1698947,1662082,1698946,1698949,1698950,1629373,1510576,1662142,158890,126120,1301694,1301692,109745,1199264,1629354,826552,1694892,1375394,1662127,1662126,1694894,1510575,1694881,826549,1694880,1768611,826550,158905,826551,1768609,52412,1846433,826546,1662119,826547,1662118,470214,1633497,470213,470212,1633499,27844,1633501,142532,1633502,470208,1633503,818373,818374,1633490,474315,474314,1633493,60622,474313,1629399,1662153,1633481,1662152,1629386,1633482,113874,1633483,1633484,142551,1629389,1633487,1699008,1694915,1699011,1633477,470233,1633478,1760507,158944,126183,72934,720109,470252,1694964,36080,1445095,81138,1723625,1723628,1633504,134396,15618,1768732,470284,1699093,826625,1580311,1301763,1768714,109840,1268992,1301767,1301766,171290,150811,1723651,1723648,101660,1670458,150822,1670461,48422,150820,1432883,73005,208174,118063,64815,101678,56624,1699115,1699114,1699117,1199402,7481,1768736,1699106,1768737,1699109,1699111,101697,142659,1768795,1768793,142662,1723740,1580371,1699154,1699157,1699156,1768791,1699159,1768788,1699158,1723723,470357,470356,470355,1105220,1768782,150871,462162,1723724,138587,1080650,56674,109923,449892,1301878,126311,474478,159080,1301880,89452,474474,191852,474473,93559,1502560,785778,1723747,1723744,1768800,1301864,122236,52606,122239,1768805,572808,1695128,126339,56707,1695133,1723807,1695135,1330588,1633680,171403,1633681,44426,1269150,1633685,159117,822685,1629578,1629579,114069,1215879,1502595,1633678,1633679,105880,126367,1785220,597417,1633720,1633721,1633722,1269168,105893,150949,196010,474543,1629617,1633715,1633716,1633717,118190,126382,1633719,1768874,1768875,1768873,11701,118196,322993,1629613,118201,159163,1695139,1695138,1269167,1723814,1768870,1723812,1768869,716233,1351120,1723856,101834,1768913,1699284,1723861,1768917,1768906,101843,1768904,1768905,1301959,1768910,1699276,1723855,1768911,1863113,1699279,1723852,1768908,1711554,1301960,462298,458200,1768901,818668,1633785,1662456,1633786,1633787,155110,1105398,15852,1105405,81395,118263,1785315,69116,69118,1695256,1748507,1834520,105989,712206,19973,1302037,712205,1076759,1076760,1695249,101898,1461786,1633812,1670677,1633813,1695254,1670665,48657,1695243,1195521,163348,712210,470558,7706,470557,712208,470556,712209,462363,470555,1670661,470554,1629753,470564,171560,1629746,1748529,101937,1629737,1629738,1748520,101942,1629743,1076776,1629732,1695269,1748518,1748519,1797722,1748568,56899,712269,1748562,1748560,56907,470604,1748566,1748567,1748565,470613,1797705,470612,1748558,1748557,470622,1752645,208483,724578,89706,1875564,126582,470654,474749,474748,474747,474746,474745,188029,1080943,323205,61058,474757,474756,474755,1785502,134789,1564319,1629840,1564317,1564315,470666,470665,1072798,1629834,470676,1568387,470674,1629838,470672,1769144,163493,1564336,1502911,1695411,1769137,474793,474792,470711,1564327,1769130,1302178,1564326,470709,1564325,470708,1629867,1699498,1769129,1564323,1564322,1699500,1564321,1629870,48823,1769133,470719,1769122,159419,470718,1564334,1564333,1769120,52923,1564332,470713,1564329,179901,470712,1502889,1564328,1699546,470721,1724124,470720,1363678,470730,1363673,470729,1699543,470728,1629896,724697,712415,1629889,1629893,474854,163559,77549,77550,118513,151282,474870,61178,1081066,1175277,1498859,1699556,118527,48895,16129,1662747,474884,28421,474882,1601309,474881,474880,1601311,1830684,1601297,1601298,1842966,1281823,167695,1601301,114447,1601302,470807,1609480,470806,28442,98075,53021,1081102,470808,474919,474918,474917,724777,470820,470819,470818,470817,470816,1228602,1777458,1425214,114477,724774,1228607,1601320,470836,1281824,470835,470834,48956,1081132,122687,110402,69448,118600,110413,982875,1646405,667479,8030,1302387,1601400,1302386,1449844,1875838,85861,1699708,1601407,1699710,479086,1699696,1830769,61292,1601397,1699700,118639,171884,1601398,126830,1326950,1265510,171893,36732,171902,667511,1769370,171904,708489,667535,470913,1769373,36746,1503132,1159068,1326977,171931,1613698,167836,36767,1601415,1281971,155556,1470385,1630143,40879,135090,1327015,1605547,1306533,114617,147386,44990,77759,73664,1564630,1282001,1564629,40899,110532,913354,929734,1564638,561090,1564632,167890,1630152,28626,1630154,1888207,114649,49113,167896,192473,1630150,126946,73701,471011,1695741,1601534,1667057,1667056,114667,1703923,819175,1409022,1081341,90095,1433595,1695721,122864,1667051,1667053,708607,1667055,1667054,126969,1667042,1695714,1695719) group by keyWord order by h desc limit 50";
        obj.put("query",sqlStr);
        final String s = HttpUtils.httpPostRequest("http://106.14.21.57:9200/_sql",headers, obj.toJSONString());
        System.out.println(s);
    }

}
